;;; This example is adapted from the project website at
;;; https://dthompson.us/projects/chickadee.html.

(import
 (except (rnrs base) map)
 (only (guile)
       lambda* λ)
 ;; GNU Guile batteries
 (ice-9 exceptions)
 ;; Chickadee libs
 (chickadee)
 (chickadee math vector)
 (chickadee graphics sprite)
 (chickadee graphics texture))


(define sprite #f)


;; The procedure load is called before the game loop starts
;; to run. It is used to initialize resources, as in this
;; case the sprite, by loading an actual image into
;; sprite. The manual mentions, that this procedure can be
;; used for initializations, which already require an OpenGL
;; context, which Chickadee uses.
(define load
  (λ ()
    (set! sprite (load-image "images/chickadee.png"))))


;; Draw is called with one value, a so called alpha value,
;; by the run-game procedure.
(define draw
  (λ (alpha)
    ;; draw-sprite shows a sprite at the also given
    ;; position.
    (draw-sprite sprite (vec2 256.0 176.0))))


;; run-game is the entry point of Chickadee.
(run-game #:load load #:draw draw)
